<?php
session_start();
include ("shop_top.php");
// $act = !empty($_GET['act']) ? trim($_GET['act']) : 'login';	
// $t   = !empty($_GET['t']) ? intval($_GET['t']) : '';
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table7 pt20">
  <tr>
    <td><table width="100" border="0" align="center" cellpadding="0" cellspacing="0" class="center">
      <tr>
        <td height="15"></td>
      </tr>
    </table>
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="center mt20">
      <tr>
        <td width="238" align="center" valign="top"><table width="235" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/in08.jpg" width="235" height="50" /></td>
          </tr>
          <tr>
            <td height="600" align="left" valign="top" class="table8"><table width="100" border="0" align="center" cellpadding="0" cellspacing="0" class="center">
              <tr>
                <td height="15"></td>
              </tr>
            </table>
<?php
include ("left.php");
?>
            </td>
          </tr>
        </table></td>
        <td align="center" valign="top">
<table width="760" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <?php
  // if($_GET['show']!=0){
  if(!empty($_SESSION['userid']))
  {
  $rowhy=$db->getarray($db->query("select * from wkcx_hy where id=".$_SESSION['userid']));
  $name=$rowhy['yonghuming'];
  ?>  
    <td width="12"><img src="images/img26.gif" width="12" height="31" /></td>
    <td width="484" align="left" background="images/img28.gif" class="bold fontcolor1">您好<?php echo $name;?>，欢迎光临！</td>
    <td width="484" align="right" background="images/img28.gif" class="text1"><a href="shop_huiyuan.php?act=upd">修改个人信息</a> | <a href="shop_huiyuan.php?act=che">我的购物车</a> | <a href="shop_huiyuan.php?act=loginout">退出登录</a></td>
    <td width="10"><img src="images/img27.gif" width="12" height="31" /></td>
  <?php
  }else{
?>
    <td width="12"><img src="images/img26.gif" width="12" height="31" /></td>
    <td width="484" align="left" background="images/img28.gif" class="bold fontcolor1">您还没登录！ </td>
    <td width="484" align="right" background="images/img28.gif" class="text1"><a href="shop_huiyuan.php?act=login">点击登录</a> | <a href="shop_huiyuan.php?act=zhuce">点击注册</a> | <a href="shop_index.php">返回商城首页</a></td>
    <td width="10"><img src="images/img27.gif" width="12" height="31" /></td>
<?php
  }
  // }
  ?>
  </tr>
</table>

<table width="650" height="41" border="0" align="center" cellpadding="0" cellspacing="3">
  <tr>
    <td width="228" align="left" class="bold"><p></p></td>
    <td width="212" height="35" align="center" class="text"></td>
    <td width="198" align="center" class="text"></td>
  </tr>
</table>

<table width="50" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<?php
	$did          = time();
	$did		  = Date($did+3600*8);
	$did          = date('YmdHis',$did) ;
	$did 		  = $did.strval(rand("1111","9999"));
	$add_time	  = time();
	$add_time	  = GetDateTime($add_time+3600*8);
?>
订单号：<?php echo $did;?>
时间：<?php echo $add_time;?>
<table width="100%" height="39" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="500" valign="top">
			<form name=alipayment action="alipaydbjy/alipayapi.php" method="post" target="_blank" onsubmit="check()">
              <table width="680" height="35" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FBE6FB">
                  <tr>
                    <td width="41" align="center" class="zise3">序号</td>
                    <td width="99" align="center" class="zise3">配件名称</td>
                    <td width="77" align="center" class="zise3">配件价格</td>
                    <td width="67" align="center" class="zise3">数量</td>
                    <td width="127" align="center" class="zise3">金额</td>
                    </tr>
                </table>
				<?php
				$sql1="SELECT a.id,a.sl,b.pj_name,b.pj_jiage FROM `wkcx_che` as a,wkcx_peijian as b WHERE a.userid=".$_SESSION['userid']." and a.chuli=0 and a.pj_id=b.pj_id order by a.add_time asc";
                $res1=$db->query($sql1);
                $i=1;
                $jine=0;
				$num=0;
				while($row1=$db->getarray($res1)){
				?>
                <table width="680" height="35" border="0" align="center" cellpadding="0" cellspacing="0" class="xxx">
                  <tr>
                    <td width="41" align="center" class="black">
					<input type="hidden" name='che_id' value="<?php echo $row1['id'];?>" /><input type="hidden" name='action' value="chedel" />
					<?php echo $i;?></td>
                    <td width="99" align="center" class="black"><?php echo $row1['pj_name'];?></td>
                    <td width="77" align="center" class="black"><?php echo $row1['pj_jiage'];?></td>
                    <td width="67" align="center" class="black"><?php echo $row1['sl'];?></td>
                    <td width="127" align="center" class="black">￥<?php echo ($row1['pj_jiage']*$row1['sl']);?></td>
                    </tr>
                </table>
<?php
$jine += $row1['pj_jiage']*$row1['sl'];
$num += $row1['sl'];
$che_ids[]=$row1['id'];
$i++;
}
?>
<br /><p align="center">合计数量：<?php echo $num; ?>&nbsp;&nbsp;合计金额：￥<?php echo $jine; ?></p>
<?php
$xx=$db->query("select * from wkcx_hy where id=".$_SESSION['userid']);
$xxx=$db->getarray($xx);
$che_ids=implode(',',$che_ids);
?>
联系人：<?php echo $xxx['yonghuming'];?><br />
邮政编码：<?php echo $xxx['youbian'];?><br />
联系电话：<?php echo $xxx['dianhua'];?><br />
联系地址：<?php echo $xxx['dizhi'];?><br />
<hr /><br />
<div align="center">
<?php
$str=$did."#".$che_ids."#".$_SESSION['userid']."#".$num."#".$jine."#".$add_time;
?>
<input type="hidden" name="str" value="<?php echo $str;?>"/>
<input type="hidden" name="WIDout_trade_no" value="<?php echo $did;?>"/>
<input type="hidden" name="WIDprice" value="<?php echo '0.1';?>"/>
<input type="hidden" name="WIDreceive_name" value="<?php echo $xxx['yonghuming'];?>"/>
<input type="hidden" name="WIDreceive_address" value="<?php echo $xxx['dizhi'];?>"/>
<input type="hidden" name="WIDreceive_zip" value="<?php echo $xxx['youbian'];?>"/>
<input type="hidden" name="WIDreceive_phone" value="<?php echo $xxx['dianhua'];?>"/>
<br />
</div>
			<div class="clear"></div>
<input type="submit" name="submit" value="确认信息去付款" />
            </form></td>
          </tr>
        </table>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
		</td>
      </tr>
    </table></td>
  </tr>
</table>
<?php
include ("foot.php");
?>
<script language="javascript">
function check(){
if(document.myform.d_name.value==""){
    alert("联系人不能为空！");
	document.myform.d_name.focus();
	return false;
}
if(document.myform.d_tel.value==""){
    alert("联系方式不能为空！");
	document.myform.d_tel.focus();
	return false;
}
if(myform.d_address.value==""){
	alert("联系地址不能为空！");
	document.myform.d_address.focus();
	return false;
}
}
</script>
<?php
if($act == 'loginout')
	{
	$_SESSION['userid']='';
	urlMsg('退出成功！','shop_huiyuan.php?act=login');
	}
?>
</body>
</html>